function list_admin_init() {
	//取staff的部门信息展示
	$("#showstaff").click(function(){
		$("#staffdetail").fadeOut();
		$("#staffphone").fadeOut();
		var staff  = $("input[name='staff']").val();
		if(!$.trim(staff)){
			return false;
		}
		$.get("../aj_staff.php?staff="+staff, "", function(rs){
			var _msg = eval("("+rs+")");
			if(!_msg.error){
				$("#staffphone").fadeIn();
				$("input[name='phone']").val(_msg.phone);
				$("#staffdetail").html();
				tmp = "<font color=green>姓名    </font>："+_msg.name+"&nbsp;&nbsp;&nbsp;";
				tmp +="<font color=green>分机：</font>"+_msg.phone+"&nbsp;&nbsp;&nbsp;";
				tmp +="<font color=green>手机：</font>"+_msg.mobile+"&nbsp;&nbsp;&nbsp;";
				tmp +="<font color=green>部门：</font>"+_msg.subdep+"&nbsp;&nbsp;&nbsp;";
				tmp +="<font color=green>地区：</font>"+_msg.area+"&nbsp;&nbsp;&nbsp;";
				$("#staffdetail").html("<th>&nbsp;</th><td>"+tmp+"</td>");
				$("#staffdetail").fadeIn();
			}else{
                $("input[name='phone']").val("");
				$("#staffdetail").html("<th>&nbsp;</th><td>"+_msg.msg+"</td>");
				$("#staffdetail").fadeIn();
			}
		});
	})
}

$(function(){
    list_admin_init();
    var power_str = $("input[name='power_str']").val();
	var power_arr = power_str.split(',');
	for(var i=0; i<power_arr.length; i++){
		$("input:checkbox[value='" + power_arr[i] + "']").attr("checked", true);
	}
    $(".admin_click").click(function(){
    	var plat_id = $(this).attr('plat_id');
    	var module_id = $(this).attr('module_id');
    	$("input[name='plat_id']").val(plat_id);
    	$("input[name='module_id']").val(module_id);
    	$("#adminform").submit();
    });
    $(".select_all").click(function(){
    	var id = $(this).attr('id');
    	var mid = id.substr(11);
    	$("input[name='power[" + mid + "][]']").each(function(){
    		$(this).attr("checked", true);
    	});
    });
    $(".unselect_all").click(function(){
    	var id = $(this).attr('id');
    	var mid = id.substr(13);
    	$("input[name='power[" + mid + "][]']").each(function(){
    		$(this).attr("checked", false);
    	});
    });
    $(".sel_btn").click(function(){
    	var id = $(this).attr('id');
    	var wid = id.substr(8);
    	$("input[class='power_" + wid + "']").each(function(){
    		$(this).attr("checked", true);
    	});
    });
    $(".unsel_btn").click(function(){
    	var id = $(this).attr('id');
    	var wid = id.substr(10);
    	$("input[class='power_" + wid + "']").each(function(){
    		$(this).attr("checked", false);
    	});
    });
});